/*
 * @Author: 飞越疯人院 353362604@qq.com
 * @Date: 2022-06-16 15:37:12
 * @LastEditors: NaN 353362604@qq.com
 * @LastEditTime: 2023-01-13 09:48:12
 * @FilePath: \adminstration\src\Pages\Admin\config.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */

import { render } from '@testing-library/react'

// 内置选择器参数
export const BuiltInListData = {
    isYes: { title: '是否', content: ' 0: 否, 1: 是' },
    isEnabled: { title: '是否开启', content: '0:开启,1:关闭' },
    part: { title: '桥幅', content: '0:无,1:左幅,2:右幅;' },
    overTemperature: { title: '体温状况', content: '0:正常,1:超温' },
}

// 缓存选择器参数
export const RedisListData = {
    api: 'API接口',
    cameraType: '摄像头类型',
    dictionaryType: '字典类型',
    engineeringList: '施工类型',
    importantPart: '',
    menu: '菜单列表',
    organization: '组织机构',
    overTemperatureType: '超温类型',
    process: '生产工序',
    project: '项目列表',
    pushFlowTypes: '推送类型',
    role: '角色列表',
    superviseTypes: '监督类型',
}

// 接口选择器列表
export const AxiosListData = {
    apiOne: '第一个接口',
    apiTwo: '第二个接口',
    apiThr: '第三个接口',
    apiFor: '第四个接口',
}

// 数据类型
export const FieldTypeList = {
    // ! ~@ 输入类型
    // autoComplete:'自动完成',
    // iDCard:'身份证',
    // mobile:'手机号',
    input: { text: '文字输入', config: ['InputShowCount', 'InputLength'] },
    textarea: {
        text: '富文本域',
        config: ['InputShowCount', 'InputLength', 'InputMinRows', 'InputMaxRows'],
    },
    inputNumber: {
        text: '数字输入',
        config: ['InputMax', 'InputMin', 'InputStep'],
    },
    // ! ~@ 时间类型  ? 范围  时间参数
    date: { text: '选取日期', config: ['DateTime', 'DateRange', 'DateType'] },
    // ! ~@ 选择器
    select: { text: '选择器', config: ['SelectOption', 'SelectMode'] },
    treeSelect: { text: '树形选择器', config: ['SelectMode', 'SelectLevel'] },
    // ! ~@ 上传
    // upload:'上传'
}

// 临时模拟数据
export const FixedData = [
    { uuid: 'c01', tableName: '编号', code: '0', key: 'uuid' },
    { uuid: 'c02', tableName: '名称', code: '1', key: 'tableName' },
    { uuid: 'c03', tableName: '全名称', code: '1', key: 'tableName' },
]

export const getValue = e => {
    switch (e) {
        case 'uuid':
            return new Promise(res => res(uuid))
        default:
            return new Promise(res => res('暂不支持该字段'))
    }
}

const uuid = {
    dataIndex: 'uuid',
    title: '编号',
    isEnabled: true,
    valueType: 'select',
    typeConfig: {},
    sort: 0,
    width: 100,
    rules: true,
    default: false,
    defaultValue: 'uuid默认值',
    hideInAdded: true,
    hideInModify: true,
    hideInTable: true,
    hideInSearch: true,
    tooltip: false,
    tooltipInput: '',
    ellipsis: false,
    copyable: false,
}

export const BuiltInData = {
    isYes: { 0: '否', 1: '是' },
    isYesTwo: { 1: '否', 0: '是' },
    result: { 0: '合格', 1: '不合格', '': '未评定' },
    gradingresults: {
        0: '未判定',
        1: '合格',
        2: '需要二次计算',
        3: '不合格',
        4: '数据异常',
    },
    CurrveType: { 1: '上限', 2: '下限', 3: '理论', 4: '实际' },
    lorR: { 1: '左洞', 2: '右洞' },
    gender: { 0: '女', 1: '男' },
    Pass: { 0: '未通过', 1: '已通过' },
    MenuType: { 0: '菜单', 1: '功能', 2: '节点菜单' },
    isEnabled: { 0: '关闭', 1: '开启' },
    locking: { 0: '锁定', 1: '未锁' },
    alarm: { 0: '正常', 1: '报警' },
    inOrOut: { 1: '进入', '-1': '外出' },
    carInOrOut: { 1: '进入', 0: '外出' },
    part: { 0: '无', 1: '左幅', 2: '右幅' },
    alarmlve: { 1: '初级', 2: '中级', 3: '⾼级' },
    uporDown: { 1: '上限报警', 2: '下限报警', 3: '最低限报警' },
    overTemperature: { 0: '正常', 1: '超温' },
    FileType: { 0: '一般文件', 1: '图像', 2: '视频', 3: 'pdf文档' },
    ReviewStatus: { 0: '未提交', 1: '待审核', 2: '合格', 3: '不合格' },
    RequestType: {
        GET: 'GET',
        POST: 'POST',
        PUT: 'PUT',
        DELETE: 'DELETE',
        PATCH: 'PATCH',
    },
    PushFlowConfigType: {
        '-2': '处理完毕',
        '-1': '等待推送',
        0: '立刻推送',
        1: '按时间限制推送',
    },
    PatrolStatus: {
        '-1': '下单未提交',
        0: '等待接受整改',
        1: '整改中',
        2: '已整改',
        3: '合格',
        4: '不合格',
    },
    InternetOfThingsType: {
        0: '压力机',
        1: '标养室',
        2: '马歇尔',
        3: '针入度',
        4: '软化点',
        5: '万能机水泥',
        6: '万能机钢筋',
        7: '压浆',
        8: '张拉',
        9: '水泥搅拌站',
        10: '环境监测设备',
        11: '安全帽',
        12: '水泥混凝土拌和站',
        13: '气体检测',
        14: '龙门吊',
        15: '钢筋保护层',
        16: '延度仪',
        17: '路强仪抗压试验',
        18: '路强仪cbr试验',
        19: '路强仪回弹试验',
        20: '回弹仪',
        21: '抗折抗压一体机',
        22: '沥青拌合站',
    },
    OrderField: { asc: '正序', desc: '倒序' },
    excessState: { 0: '不超标', 1: '初级', 2: '中级', 3: '高级', 4: '异常' },
    layerPosition: { 1: '上面层', 2: '中面层', 3: '下面层' },
    earlyWarning: { 0: '正常', 1: '初级预警', 2: '中级预警', 3: '高级预警' },
    partText: { 无: '无', 左幅: '左幅', 右幅: '右幅' },
    componentType: { 1: '标签', 2: '梁' },
    auditStatus: { 0: '待审核', 1: '合格', 2: '不合格', '-1': '销毁' },
    camerafactory: { 1: '萤石', 2: '大华', 4: '直播' },
    CameraPTZ: { 0: '不可控', 1: '可控' },
    online: { 0: '离线', 1: '在线' },
    IsEnabled: { 0: '未启用', 1: '已启用' },
    status: { 0: '未处理', 1: '已处理' },
    warning: { 0: '正常', 1: '报警' },
    SampleStatus: { 0: '未检测', 1: '检测中', 2: '已完成' },
    sceneType: { 1: 'Mars3D', 2: 'Forge', 3: '720全景' },
    matName: {
        sieve475: ' 4.75筛孔通过率',
        asphaltratio: ' 油石比',
        temperature: '出料温度',
        waterbinderratio: '水胶比',
        cement1: '水泥用量1',
        cement2: '水泥用量2',
        cement3: '水泥用量3',
        cement4: '水泥用量4',
    },
    identity: {
        1: '工程管理公司',
        2: '片区',
        3: '项目公司',
        4: '项目',
        5: '子项目',
    },
    enterpriseFileCategory: {
        1: '母岩',
        2: '细集料',
        3: '粗集料',
        4: '基质沥青',
        5: '改性沥青',
        6: '环境稳定性',
        7: '荷载稳定性',
        8: '其他',
        9: '宣传片',
    },

    projectScheduleType: { 1: '准备阶段', 2: '建设阶段', 3: '运营阶段' },
    CurrentPeriod: { 准备阶段: '准备阶段', 建设阶段: '建设阶段', 运营阶段: '运营阶段' },
    projectType: {
        交通项目: '交通项目',
        市政项目: '市政项目',
        房建项目: '房建项目',
        开发区项目: '开发区项目',
        供热管网改造: '供热管网改造',
    },
    roadLevel: { 一级: '一级', 二级: '二级', 三级: '三级', 四级: '四级' },
    isYesText: { 是: '是', 否: '否' },
    isRenew: { 新建: '新建', 改建: '改建', 承继: '承继' },
    // 监理审核状态
    approvalStatus: {
        0: { text: '未提交', status: 'Default' },
        1: { text: '待审核', status: 'Processing' },
        2: { text: '合格', status: 'Success' },
        3: { text: '不合格', status: 'Error' },
    },
    SuperviseStatus: {
        0: '未提交',
        1: '待审核',
        2: '合格',
        3: '不合格',
    },

    // 项目三级菜单
    ProjectMenuList: {
        Home001: '项目概况001',
        PPP001: 'PPP建设模式管理程序001',
        File001: '建设程序001',
        Operate001: '运营监管001',
        Operate002: '运营监管002',
        Progress001: '进度控制001',
        Security001: '安全监管001',
        Monitor001: '视频监控001',
        Fund001: '资金管理001',
    },

    HelmetTypeList: {
        1: '安全帽',
        2: '执法记录仪',
    },
    projectStatus: {
        0: '续建项目',
        1: '新开工项目',
    },
    InfoFileType: {
        0: '附件',
        1: '富文本',
        2: '附件和富文本',
        3: '跳转网址',
    },
    PushLogsStatus: {
        0: '拉取',
        1: '上传',
    },
    projectBuildingPaymentType: {
        1: '建筑安装工程费',
        2: '征地拆迁补偿费',
        3: '工程建设其他费用',
        4: '预备费',
        5: '贷款利息费用',
    },
    projectOperationPaymentType: {
        1: '养护费用',
        2: '偿还贷款费用',
        3: '管理费用',
        4: '税费',
        5: '股东分红',
    },
    scoreType: {
        0: '第三方评分',
        1: '项目评分',
        2: '监理评分',
    },
}

// 通用表单数据
export const commonTableList = {
    uuid: {
        dataIndex: 'uuid',
        title: '编号',
        valueType: 'hidden',
        sort: 1,
        width: 100,
        hideInAdded: true,
        hideInTable: true,
        hideInSearch: true,
    },
    code: {
        dataIndex: 'code',
        title: '编码',
        valueType: 'input',
        width: 150,
        hideInSearch: true,
    },
    tableName: {
        dataIndex: 'tableName',
        title: '名称',
        valueType: 'input',
        rules: true,
        width: 150,
    },
    fullName: {
        dataIndex: 'fullName',
        title: '全名称',
        valueType: 'input',
        rules: true,
        width: 150,
    },
    organizationUuid: {
        dataIndex: 'organizationUuid',
        title: '组织机构',
        valueType: 'select',
        valueEnum: {},
        rules: true,
        width: 150,
        // render: (_, e) => <div>{JSON.parse(localStorage.getItem('ClientData')).organization.find(v => v.value === e.organizationUuid).label}</div>
    },
    projectUuid: {
        dataIndex: 'projectUuid',
        title: '项目名称',
        valueType: 'select',

        valueEnum: {},
        rules: true,
        width: 150,
    },
    parentUuid: {
        dataIndex: 'parentUuid',
        title: '父节点',
        valueType: 'treeSelect',
        fieldProps: {
            options: [],
            fieldNames: { label: 'tableName', value: 'uuid' },
        },
        rules: true,
        width: 150,
    },
    isEnabled: {
        dataIndex: 'isEnabled',
        title: '启用状态',
        valueType: 'select',
        width: 100,
        valueEnum: BuiltInData.isEnabled,
        hideInSearch: true,
    },
    sortId: {
        dataIndex: 'sortId',
        title: '排序',
        width: 100,
        valueType: 'inputNumber',
        hideInSearch: true,
    },
    remark: {
        dataIndex: 'remark',
        title: '备注信息',
        width: 200,

        valueType: 'textarea',
        hideInSearch: true,
    },
    createUserName: {
        dataIndex: 'createUserName',
        title: '创建姓名',

        width: 100,
        hideInSearch: true,
        hideInAdded: true,
        hideInModify: true,
    },
    createTime: {
        dataIndex: 'createTime',
        title: '创建时间',

        width: 200,
        hideInSearch: true,
        hideInAdded: true,
        hideInModify: true,
    },
    updateUserName: {
        dataIndex: 'updateUserName',
        title: '更新姓名',

        width: 100,
        hideInSearch: true,
        hideInAdded: true,
        hideInModify: true,
    },
    updateTime: {
        dataIndex: 'updateTime',
        title: '更新时间',

        width: 200,
        hideInSearch: true,
        hideInAdded: true,
        hideInModify: true,
    },
    systemOperation: {
        dataIndex: 'systemOperation',
        title: '操作',
        fixed: 'right',
        hideInSearch: true,
        hideInAdded: true,
        hideInModify: true,
    },
    BeginStatDate: {
        dataIndex: 'BeginStatDate',
        title: '开始日期',
        valueType: 'date',
        hideInAdded: true,
        hideInModify: true,
        hideInTable: true,
    },
    EndStatDate: {
        dataIndex: 'EndStatDate',
        title: '结束日期',
        valueType: 'date',
        hideInAdded: true,
        hideInModify: true,
        hideInTable: true,
    },
    BeginAttendanceTime: {
        dataIndex: 'BeginStatDate',
        title: '开始日期',
        valueType: 'date',
        hideInAdded: true,
        hideInModify: true,
        hideInTable: true,
    },
    EndAttendanceTime: {
        dataIndex: 'EndStatDate',
        title: '结束日期',
        valueType: 'date',
        hideInAdded: true,
        hideInModify: true,
        hideInTable: true,
    },
    BeginEntryTime: {
        dataIndex: 'BeginEntryTime',
        title: '开始时间',
        valueType: 'dateTime',
        hideInAdded: true,
        hideInModify: true,
        hideInTable: true,
    },
    EndEntryTime: {
        dataIndex: 'EndEntryTime',
        title: '结束时间',
        valueType: 'dateTime',
        hideInAdded: true,
        hideInModify: true,
        hideInTable: true,
    },
    BeginProduce: {
        dataIndex: 'BeginProduce',
        title: '开始时间',
        valueType: 'dateTime',
        hideInAdded: true,
        hideInModify: true,
        hideInTable: true,
    },
    EndProduce: {
        dataIndex: 'EndProduce',
        title: '结束时间',
        valueType: 'dateTime',
        hideInAdded: true,
        hideInModify: true,
        hideInTable: true,
    },
    BeinVideoDate: {
        dataIndex: 'BeginProduce',
        title: '开始时间',
        valueType: 'dateTime',
        hideInAdded: true,
        hideInModify: true,
        hideInTable: true,
    },
    EndVideoDate: {
        dataIndex: 'EndProduce',
        title: '结束时间',
        valueType: 'dateTime',
        hideInAdded: true,
        hideInModify: true,
        hideInTable: true,
    },
    BeginAlarmTime: {
        dataIndex: 'BeginProduce',
        title: '开始时间',
        valueType: 'dateTime',
        hideInAdded: true,
        hideInModify: true,
        hideInTable: true,
    },
    EndAlarmTime: {
        dataIndex: 'EndProduce',
        title: '结束时间',
        valueType: 'dateTime',
        hideInAdded: true,
        hideInModify: true,
        hideInTable: true,
    },
    StartTime: {
        dataIndex: 'StartTime',
        title: '开始时间',
        valueType: 'dateTime',
        hideInAdded: true,
        hideInModify: true,
        hideInTable: true,
    },
    BeginTime: {
        dataIndex: 'BeginTime',
        title: '开始时间',
        valueType: 'dateTime',
        hideInAdded: true,
        hideInModify: true,
        hideInTable: true,
    },
    EndTime: {
        dataIndex: 'EndTime',
        title: '结束时间',
        valueType: 'dateTime',
        hideInAdded: true,
        hideInModify: true,
        hideInTable: true,
    },

    StartDate: {
        dataIndex: 'StartDate',
        title: '开始时间',
        valueType: 'date',
        hideInAdded: true,
        hideInModify: true,
        hideInTable: true,
    },
    EndDate: {
        dataIndex: 'EndDate',
        title: '结束时间',
        valueType: 'date',
        hideInAdded: true,
        hideInModify: true,
        hideInTable: true,
    },
    BeginSecurityDate: {
        dataIndex: 'beginSecurityDate',
        title: '开始日期',
        valueType: 'date',
        hideInAdded: true,
        hideInModify: true,
        hideInTable: true,
    },
    EndSecurityDate: {
        dataIndex: 'endSecurityDate',
        title: '结束日期',
        valueType: 'date',
        hideInAdded: true,
        hideInModify: true,
        hideInTable: true,
    },
}

// 广度遍历
export const breadthSearch = (tree, text, url) => {
    var stark = []
    stark = stark.concat(tree)
    while (stark.length) {
        var temp = stark.shift()
        if (temp.children) stark = stark.concat(temp.children)
        if (temp[text] === url) return temp
    }
}

// 树转平
export const TreeToLevel = item => {
    let res = []
    item.forEach(key => {
        res.push(key)
        key.children && res.push(...TreeToLevel(key.children))
    })
    return res
}

// 过滤树形菜单可选
export const TreeFilterData = data => {
    let newData = data.map(v => {
        v.disabled = v.lowLevel === 0 ? false : true
        return v
    })
    newData.forEach(x => {
        x.children && (x.children = TreeFilterData(x.children))
    })
    return newData
}

// 过滤菜单
export const filterData = data => {
    var newData = data.filter(v => v.isEnabled !== 0)
    newData.forEach(x => x.children && (x.children = filterData(x.children)))
    return newData
}

// 排序字段
export const sortField = order => {
    let data = []
    order.forEach(item => {
        data = [
            ...data,
            {
                dataIndex: item.name,
                title: `${item.label}排序`,
                valueType: 'select',
                valueEnum: { asc: '正序', desc: '倒序' },
                hideInAdded: true,
                hideInModify: true,
                hideInTable: true,
            },
        ]
    })
    return data
}
